package com.example.service.impl;

import com.example.dao.Dept1Mapper;
import com.example.pojo.Dept1;
import com.example.service.Dept1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class Dept1ServiceImpl implements Dept1Service {
    @Autowired
    Dept1Mapper dept1Mapper;
    //查询所有
    @Override
    public List<Dept1> list() {
        List<Dept1> dept1List=dept1Mapper.list();
        return dept1List;
    }
    //添加数据
    @Override
    public void add(Dept1 dept1) {
        dept1.setCreateTime(LocalDateTime.now());
        dept1.setUpdateTime(LocalDateTime.now());
        dept1Mapper.insert(dept1);
    }
    //根据id查询
    @Override
    public Dept1 SelectById(Integer id) {
        Dept1 dept1=dept1Mapper.findId(id);
        return dept1;
    }
    //修改数据
    @Override
    public void update(Dept1 dept1) {
        dept1.setUpdateTime(LocalDateTime.now());
        dept1Mapper.update(dept1);
    }

    @Override
    public void DeleteByid(Integer id) {
        dept1Mapper.deleteById(id);
    }


}
